import Vue from "vue";
//==============================StringUtil=================================
const loginUtil = {
  //是否为空判断
  goLogin:function(self){
	   
	  uni.showModal({
	  	title: '提示',
	  	content: '暂未登录',
	  	success:res=> {
	  		if (res.confirm) {
	  			
	  			//#ifdef MP-WEIXIN
	  			uni.switchTab({
	  				url:"../pages/tab4"
	  			})
	  			//#endif
				
				//#ifdef H5
				uni.navigateTo({
					url:'../pagesB/login/login'
				})
				//#endif
	  			
	  			//#ifdef APP-PLUS
	  			
	  			const jv = uni.requireNativePlugin('JG-JVerification');
	  			
	  			jv.addCustomViewsClickCallback(id=>{
	  				// // //console.log("自定义点击"+id)
	  				
	  				jv.dismissLoginAuth(true, res=>{
	  				    uni.navigateTo({
	  				    	url:'../pagesB/login/login'
	  				    })
	  				})
	  			});
	  			// jv.setDialogTheme(410, 390, 0, 0, false)
	  			jv.setCustomUIWithConfigAndroid({
	  				// 设置状态栏与导航栏同色
	  				setStatusBarColorWithNav: true,
	  				setNumberColor:0xff2c2c2c,
	  				setNumberTextBold: true,
	  				setNavColor:0xff#4578F7,
	  				setLogBtnText:"手机号码一键登录",
	  				setPrivacyState:true,
	  				// 选择框隐藏
	  				setPrivacyCheckboxHidden: true,
	  				// 隐私条款文字居中
	  				setPrivacyTextCenterGravity: true,
	  				setPrivacyNameAndUrlBeanList:[{
	  					name:"隐私政策",
	  					url:"https://admin.jjdaojia.com/api/xieyi/yulan/2",
	  					beforeName:",",
	  					afterName:","
	  				},{
						name:"用户协议",
						url:"https://admin.jjdaojia.com/api/xieyi/yulan/1",
						// beforeName:","
						// afterName:","
					}],
	  				setAppPrivacyColor:[0xff4169E1,0xffFF6347],
	  				setPrivacyTextSize:12,
	  				setPrivacyCheckboxSize:14,
	  				enableHintToast:true,
	  				enableHintToastText:"自定义提示linux",
	  				setLoadingViewEnable:false,
	  				setStatusBarTransparent:false,
	  				addCustomViews:[{
	  					type:"text",
	  					finishFlag:false,
	  					id:"id1",
	  					width:200,
	  					height:50,
	  					text:"使用手机验证码登录",
	  					textSize:14,
	  					align:15,
	  					margins:[120,0,0,0],
	  				}]
	  			});
	  			
	  
	  			jv.loginAuth({
	  			        autoFinish:true,
	  			        timeout:5000
	  			    },result=>{
	  			        // 结果监听
	  			        let code = JSON.parse(JSON.stringify(result)).code;
	  					let content = JSON.parse(JSON.stringify(result)).content;
	  					
	  					
	  					 //console.log(content,code);
	  					if(code==6000){
	  						self.$request("kehu/user/loginByJiGuang",{content:content}).then(res=>{
	  							 //console.log("111111111111111111111",res.code);
	  							self.$store.commit('setToken',res.msg);
								uni.reLaunch({
									url:'/pages/tab1'
								})
	  						}).catch(err=>{
								self.$store.commit('setToken','');
							})
	  					}else if(code==6001){
	  						uni.showModal({
	  							title:'提示',
	  							content:'数据网络未开启'
	  						})
	  					}else if(code==2016){
	  						uni.showModal({
	  							title:'提示',
	  							content:'当前网络环境不支持认证',
								showCancel:false
	  						})
	  					}
	  			    },event=>{
	  					// // //console.log(JSON.stringify(event))
	  			    })
	  			//#endif
	  		}
	  	}
	  })
  }
};
Vue.prototype.loginUtil = loginUtil;
 
export default {};
